export interface Configtype {
	hasborder: boolean;
	heightLight: boolean;
	enabled: boolean;
	maxDepth: number;
	production: boolean;
	onlineProduct: {
		enabled: boolean;
		gitBranchInclude: string[];
	},
	use: {
		userList: Array<{
			name: string;
			avatar: string;
		}>|[],
		userBaseLogs: Record<string,BaseConfig> | {}
	};
	img: {
		maxWidth: number;
		maxHeight: number;
	};
	base: BaseConfig;
	info: Info;
	error: ErrorType;
	success: Success;
	warning: Warning;
	equal: equalType;
}


export interface BaseFunction<T> extends Function {
	(...args: any[]): any;
}
export interface ErrorType extends BaseConfig {}
export interface Success extends BaseConfig {}
export interface Warning extends BaseConfig {}
export interface Info extends BaseConfig {}
export interface equalType {}
export type BaseConfig = {
	title: string | number;
	titleColor: string;
	contentColor: string;
	backgroundColor: string;
	borderColor: string;
};

export type SelectableConfig<T> = {
	[key in keyof T]?: T[key] extends object
		? SelectableConfig<T[key]>
		: T[key] | undefined;
};

// 创建一个泛型类型帮助函数，用于合并对象属性到函数上
export function createExtendedFunction<T>(
	func: Function,
	properties: T,
	prop?: 'base',
): BaseFunction<T> {
	// 将传入的函数转换为 BaseFunction 类型
	const extendedFunction = func as BaseFunction<T>;
	// 遍历传入对象的属性，并将其赋值给扩展函数
	for (const key in properties) {
		if(prop){
		// @ts-ignore
			if (properties.hasOwnProperty(key)) {
				if (prop !== key) {
					(extendedFunction as any)[key] = properties[key];
				}
			}
		} else {
			// @ts-ignore
			if (properties.hasOwnProperty(key)) {
				(extendedFunction as any)[key] = function (...args:any) {
					console.log(...args);
				};
			}
		}
	}
	return extendedFunction;
}
